﻿using Newtonsoft.Json.Linq;
using System;
using System.Windows;
using System.Windows.Controls;
using wpf_print.data;

namespace wpf_print.view
{
    internal class FootView
    {
        public static Grid GeFootView(JObject obj)
        {
            Grid grid = new();

            RowDefinition rd = new();
            grid.RowDefinitions.Add(rd);
            for (var i = 0; i < 3; ++i)
            {
                ColumnDefinition cd = new();
                grid.ColumnDefinitions.Add(cd);

            }


            System.Windows.Controls.Image img = CreatCodeQR.CreateQRCode(obj["moreData"]["ackInfo"]["sequence"] + "p"+ obj["page"]["pageNum"], new Thickness(-10, 0, 0, 0));
            System.Windows.Controls.Image img1 = CreatCodeQR.CreateQRCode(obj["moreData"]["ackInfo"]["sequence"] + "p" + obj["page"]["pageNum"], new Thickness(20, 0, 0, 0));
            JObject postedJObject = new();
            JObject cssJObject = new();
            cssJObject.Add("width", 580);
            cssJObject.Add("fontSize", 14);
            cssJObject.Add("fontWeight", "none");
            postedJObject.Add("cssStyle", cssJObject);
            postedJObject.Add("name", "第"+obj["curPageNum"] +"页 ");
            postedJObject.Add("value", "共"+ obj["allPageNum"] + "页");
            WrapPanel warPanel = BoxView.GetBoxView(postedJObject);
            warPanel.HorizontalAlignment = HorizontalAlignment.Left;
            warPanel.VerticalAlignment = VerticalAlignment.Center;
            img.HorizontalAlignment = HorizontalAlignment.Left;
            img1.HorizontalAlignment = HorizontalAlignment.Right;
            if ((string)obj["moreData"]["lossPreventionPrint"] == "0")
            {
                Grid.SetRow(warPanel, 0);
                Grid.SetColumn(warPanel, 1);
            }
            else {
                Grid.SetRow(warPanel, 0);
                Grid.SetColumn(warPanel, 1);
                Grid.SetRow(img, 0);
                Grid.SetColumn(img, 0);
                Grid.SetRow(img1, 0);
                Grid.SetColumn(img1, 2);
                grid.Children.Add(warPanel);
                grid.Children.Add(img);
                grid.Children.Add(img1);
            }
           
            return grid;


        }
    }
}
